<%@page import="com.eos.orm.mybatis.model.SysCustomer"%>
<%@page import="com.eos.orm.mybatis.model.SysProduct"%>
<%@page import="com.eos.orm.mybatis.model.ViewDeliverList"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html; charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<% 
List<ViewDeliverList> vdList = (List<ViewDeliverList>)request.getAttribute("viewDeliverList");
List<SysProduct> productList = (List<SysProduct>) request.getAttribute("productList");
List<SysCustomer> customerList = (List<SysCustomer>) request.getAttribute("customerList");
%>
<style>
.searchBar .searchContent td{padding-right:10px;} 
</style>
<script type="text/javascript">
	$(document).ready(function(){
		$("#send_selProductId").change(function(){
			var $this = $(this);
			if($this.val()== ""){
				$("#send_selBrandId option").not(":first").remove();
			}else{
				var txt = $("#sp_send").text(), proId = $this.val();
				if($.trim(txt) != ""){
					$("#send_selBrandId option").not(":first").remove();
					var selJson = $.parseJSON(txt);
					$.each(selJson, function(i){
						var key2 = 'pro_'+proId;
						if(i == key2){ 
							$.each(selJson[i], function(j){
								$("#send_selBrandId").append('<option value="'+selJson[i][j].id+'">'+selJson[i][j].brandName+'</option>');
							});
						}
					});
				}
			}
	 });
		
		initPro(); 
	});
	
	function initPro(){
		var txt = $("#sp_send").text(), mProId = $("#send_productId").val(), mBrandId = $("#send_brandId").val(); 
		if($.trim(txt) != ""){  
			$("#send_brandId option").not(":first").remove();
			var selJson = $.parseJSON(txt), sel='';
			$.each(selJson, function(i){
				var key2 = 'pro_'+mProId;
				if(i == key2){ 
					$.each(selJson[i], function(j){
						if(mBrandId==selJson[i][j].id){sel= ' selected="selected" ';}
						$("#send_selBrandId").append('<option'+ sel+' value="'+selJson[i][j].id+'">'+selJson[i][j].brandName+'</option>');
						sel = '';
					});
				}
			});
		}
	}
</script>
<form id="pagerForm" method="post" action="billOfSendList">	
	<input type="hidden" name="pageNum" value="${param.pageNum}" />	
</form>
<div class="pageHeader">
	<span style="display: none;" id="sp_send">${brandOfProductJson }</span>
	<input type="hidden" id="send_productId" value="${productId }" />
	<input type="hidden" id="send_brandId" value="${brandId }" />
	<form onsubmit="return navTabSearch(this);" rel="pagerForm"  method="post" action="billOfSendList">
	<div class="searchBar" >
	<input type="hidden" name="numPerPage" value="${numPerPage}" />
	<input type="hidden" name="pageNum" value="${pageNum}" /> 
	<table class="searchContent" >
			<tr>
				<td>
					<label>唯一码:</label>
					<input type="text" name="barCode" value="${barCode }" size="16"  />
				</td>
				<td>
					 <label style="width: 40px;">供应商:</label> 
                     <select name="customerId" style="width:140px;">
                     	<option value="">-选择供应商-</option>
                     	<c:forEach var="cu" items="${customerList }">
                     	<option value="${cu.id }" <c:if test="${cu.id eq customerId }">selected="selected"</c:if>>${cu.customerName }</option>
                     	</c:forEach>
                     </select>
				</td>
				<td>
					<label style="width:50px;">品 名:</label>
					 <select name="productId" id="send_selProductId">
                     	<option value="">-选择品名-</option>
                     	<c:forEach var="pro" items="${productList }">
                     	<option value="${pro.id }" <c:if test="${pro.id eq productId }">selected="selected"</c:if>>${pro.productName }</option>
                     	</c:forEach>
                     </select>
				</td>
				<td>
					 <label style="width:40px;">品 牌:</label> 
					 <select name="brandId" id="send_selBrandId">
                     	<option value="">-选择品牌-</option> 
                     </select>
				</td>				
				 
				<td>
					<label style="width:50px;">发货时间:</label>  
					<input type="text" name="sendTime" size="12" value="${sendTime }" style="float:left;" class="date" readonly="readonly"/>
					<a class="inputDateButton" href="javascript:;">选择</a>
				</td>
				<td style="">
					 <div class="subBar">
						<ul>
							<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
						</ul>
					</div>
				</td>
			</tr>
		</table>
	</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<li>
				<a class="add" width="500" height="310" style="font-weight: bold;color:#4BBB13;" href="addBillOfSend?navTabId=addBillOfSend" rel="addBillOfSend" target="dialog" maxable="false" mask="true"><span>导入发货清单(Excel)</span>
				</a>
			</li>
			<!--<li class="line">line</li>
			<li>
				<a class="edit"  width="580" height="450" style="font-weight: bold;color:#6495ED;" href="editEmp?empId={sid_empId}&navTabId=editEmp"
					 target="dialog" maxable="false" mask="true" rel="editEmp" title="编辑用户信息"><span>编辑用户</span>
				</a>
			</li>
			--><li class="line">line</li>
			<li>
				<a class="delete" style="font-weight: bold;color:#C1272A;" href="delBillOfSend?billOfSendId={sid_billOfSendId}"
					target="dialog" mask="true" width="480" height="330" title="要删除发货清单明细数据"><span>删除</span>
				</a>
			</li>
			<li class="line">line</li>
			<li>
				<a class="delete" style="font-weight: bold;color:#C1272A;" width="450" height="262" href="batchDelBillOfSend?navTabId=batchDelBillOfSend" target="dialog" maxable="false" mask="true"><span>批量删除</span>
				</a>
			</li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="115">
		<thead>
			<tr>
				<th>序号</th>
                <th>发货清单ID</th>
                <th>供应商名称</th>
                <th>品名</th>
                <th>品牌</th>
                <th>型号</th>
                <th>颜色</th>
                <th>产品唯一码</th>
                <th>箱标签号</th>   
                <th>发货时间</th>
                <th>配置</th>
                <th>备注</th>
                <th>状态</th>            
			</tr>
		</thead>
		<tbody>
		   <% 
		   if(null != vdList){
		   int i = 1;
		      for(ViewDeliverList vd : vdList){
		      %>
		      <tr target="sid_billOfSendId" rel="<%=vd.getId() %>">
                	<td><%=i++ %></td>
                	<td><%=vd.getId() %></td>
                	<td>
                	<% 
                	if(null != customerList){
                	  for(SysCustomer su : customerList){
                	     if(su.getId().intValue() == vd.getCustomerId()){
                	     	out.print(su.getCustomerName());
                	     	break;
                	     }
                	  }
                	}
                	%>
                	</td>
                	<td>
                	<%
                	 if(null != productList){
                	   for(SysProduct pro : productList){
                	     if(pro.getId() == vd.getProductId().intValue()){
                	     	out.print(pro.getProductName());
                	     	break;
                	     }
                	   }
                	 }
                	 %>
                	</td>
                	<td><%=vd.getBrandName() %></td>
                	<td><%=vd.getModelName() %></td>
                	<td><%=vd.getColourName() %></td>
                	<td><%=vd.getBarCode() %></td>
                	<td><%=vd.getCaseNumber() %></td>
                	<td><%=vd.getDeliverTime() %></td>
                	<td><%=vd.getModelDesc()==null ? "" : vd.getModelDesc() %></td>
                	<td><%=vd.getDeliverDesc() %></td>
                	<td>
                	 <% 
                	  if("0".equals(vd.getStatus())){ %>
                	    <a style="color:#006400;text-decoration: none;">正常</a>
                	 <% }else{
                	 %>
                	        <a style="color:#f00;text-decoration: none;">删除</a>
                	 <%} %>
                	</td>
                </tr>
		     <% }
		   }
		   %>
		</tbody>
	</table>

	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<!-- pageNum:1是当更改numPerPage时，使pageNum=1重新开始，否则可能无数据 -->
			<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value,pageNum:1})">
				<option value="15" ${numPerPage==15?'selected':''}>15</option>
				<option value="20" ${numPerPage==20?'selected':''}>20</option>
				<option value="25" ${numPerPage==25?'selected':''}>25</option>
				<option value="50" ${numPerPage==50?'selected':''}>50</option>
				<option value="100" ${numPerPage==100?'selected':''}>100</option>
			</select>
			<span>条，共${totalCount }条 </span>
		</div>		
		<div class="pagination" targetType="navTab" totalCount="${totalCount }" numPerPage="${numPerPage}" pageNumShown="5" currentPage="${pageNum }"></div>

	</div>
</div>
